public class Solution204 {
    public int countPrimes(int n) {
        int[] f=new int[n];
        int ans=0;
        for (int i=2;i<n;i++){
            if (f[i]==0){
                f[i]=1;
                ans++;
                for (int j=2;j<=(n-1)/i;j++){
                    f[i*j]=1;
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution204().countPrimes(10));
    }
}
